/**
 * Created with IntelliJ IDEA.
 * User: happyiu
 * Date: 2022-01-26
 * Time: 14:40
 * Description:
 */
public class TestDemo {
    //使用while循环建立类似的“恢复模型”
    public static void main(String[] args) throws Exception{
        int i = 0;
        while(i<10){
            try{
                if(i<10){
                    throw new Exception();
                }
                else
                    System.out.println("程序正常运行");

            }catch(Exception e){
                e.printStackTrace();
                System.out.println("程序出现异常，尝试第"+(i+1)+"次连接........");
                i++;
            }
        }

        System.out.println("连接成功！！程序继续执行" );
    }
}

/*public class TestDemo {

    private static void testMethod() {

        System.out.println("testMethod");

    }

    public static void main(String[] args) {

        ((TestDemo) null).testMethod();

    }

}*/
